package labox.innovation.gameserver.network.clientpackets;

import java.util.Map.Entry;

import labox.innovation.gameserver.model.actor.instance.FuzePcInstance;
import labox.innovation.gameserver.network.serverpackets.GUIList;
import labox.innovation.pay.DepositConfig;
import labox.innovation.pay.PayCard;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RequestDepositGUI extends L2GameClientPacket {
	private static Logger log = LoggerFactory.getLogger(RequestDepositGUI.class);

	private static final String C_REQUESTDEPOSITGUI = "C_RequestDepositGUI";

	// private byte depositType;

	@Override
	public String getType() {
		// TODO Auto-generated method stub
		return C_REQUESTDEPOSITGUI;
	}

	@Override
	protected void readImpl() {
		// depositType = readByte();
	}

	@Override
	protected void runImpl() {
		FuzePcInstance active = getClient().getActiveChar();
		if (active == null) {
			return;
		}
		StringBuilder sb = new StringBuilder();
			sb.append("<form nm='paymethod' tl='充值方式' bl='确定' ol='check()' >");
		sb.append("\n");
		sb.append("<tb ln='n' w='98%'>");
		sb.append("\n");
		sb.append("<tb ln='l' bt='0'>");
		sb.append("\n");
		sb.append("<tr><td><a pl='min'>请选择充值方式</a></td></tr>");
		sb.append("\n");
		sb.append("<tb ln='l' w='95%'>");
		sb.append("\n");
		for (Entry<String, PayCard> entry : DepositConfig.getALLPAYCARDS().entrySet()) {
			sb.append("<tr><td><a nm='" + entry.getValue().getPayId() + "' cmd='' pic='89' oc='sure()'>" + entry.getValue().getName() + "</a></td></tr>");
			sb.append("\n");
		}
		sb.append("<tr h='5'><td></td></tr>");
		sb.append("\n");
		sb.append("</tb>");
		sb.append("\n");
		sb.append("</tb>");
		sb.append("\n");
		sb.append("<tb ln='n'>");
		sb.append("\n");
		sb.append("<tr><td><a>您的充值成功后，元宝将在30分钟内到账。如有问题请咨询乾坤客服：021-32504360</a></td></tr>");
		sb.append("\n");
		sb.append("</tb>");
		sb.append("\n");
		sb.append("</tb>");
		sb.append("\n");
		sb.append("<s>");
		sb.append("\n");
		sb.append("sub sure()");
		sb.append("\n");
		sb.append("if(!isDef(\"map\"))");
		sb.append("\n");
		sb.append("list[" + DepositConfig.getALLPAYCARDS().size() + "]");
		sb.append("\n");
		for (Entry<String, PayCard> entry : DepositConfig.getALLPAYCARDS().entrySet()) {
			sb.append("list[" + entry.getValue().getPayId() + "]=\"" + entry.getValue().getMoney() + "\"");
			sb.append("\n");
		}
		sb.append("def(\"map\",list)");
		sb.append("\n");
		sb.append("eif");
		sb.append("\n");
		sb.append("popForm(\"paymethod\",\"pay\")");
		sb.append("\n");
		sb.append("name=getFocusName(\"paymethod\")");
		sb.append("\n");
		sb.append("setOption(\"pay.monlist\",map[parseInt(name)])");
		sb.append("\n");
		sb.append("setVal(\"pay.type\",name)");
		sb.append("\n");
		sb.append("ret");
		sb.append("\n");
		sb.append("</s>");
		sb.append("\n");
		sb.append("<form nm='pay' tl='充值' bl='确定' ol='check()' >");
		sb.append("\n");
		sb.append("<s>");
		sb.append("\n");
		sb.append("sub check()");
		sb.append("\n");
		sb.append("if(inputNull(\"ka\")|inputNull(\"mi\"))");
		sb.append("\n");
		sb.append("notice(\"请正确的填写卡号和密码!\")");
		sb.append("\n");
		sb.append("ret");
		sb.append("\n");
		sb.append("else");
		sb.append("\n");
		sb.append("popForm(\"pay\",\"surepay\")");
		sb.append("\n");
		sb.append("setVal(\"surepay.st\",getVal(\"type\"))");
		sb.append("\n");
		sb.append("setText(\"surepay.sk\",getIs(\"ka\"))");
		sb.append("\n");
		sb.append("setText(\"surepay.sm\",getIs(\"mi\"))");
		sb.append("\n");
		sb.append("setText(\"surepay.sj\",\"\"+getNum(\"monlist\"))");
		sb.append("\n");
		sb.append("eif");
		sb.append("\n");
		sb.append("ret");
		sb.append("\n");
		sb.append("</s>");
		sb.append("\n");
		sb.append("<tb ln='n' w='95%' bt='8'>");
		sb.append("\n");
		sb.append("<tb ln='n' w='95%'>");
		sb.append("\n");
		sb.append("<tr><td><a nm='type'/></td></tr>");
		sb.append("\n");
		sb.append("<tr><td>请输入充值卡卡号</td></tr>");
		sb.append("\n");
		sb.append("<tr><td><i nm='ka' t='e' w='176'/></td></tr>");
		sb.append("\n");
		sb.append("<tr><td>请输入充值卡密码</td></tr>");
		sb.append("\n");
		sb.append("<tr><td><i nm='mi' t='e' w='176' /></td></tr>");
		sb.append("\n");
		sb.append("<tr>");
		sb.append("\n");
		sb.append("<td>选择充值金额<ddl nm='monlist'");
		sb.append("\n");
		sb.append("list='10元|10:20元|20:30元|30:40元|40:50元|50'/></td>");
		sb.append("\n");
		sb.append("</tr>");
		sb.append("\n");
		sb.append("</tb>");
		sb.append("\n");
		sb.append("</tb>");
		sb.append("\n");
		sb.append("<tb ln='n' w='95%' >");
		sb.append("\n");
		sb.append("<tr><td ><a c='ffffff'>请输入充值卡卡号：");
		sb.append(" 充值时你务必选择与充值卡面额相同的金额，否则会导致充值失败和充值卡报废。此规定为充值卡系统规定，请玩家务必注意");
		sb.append("。因充值面额不符导致的充值失败或充值卡报废，交易金额系统不予返还。");
		sb.append("</a></td></tr>");
		sb.append("\n");
		sb.append("</tb>");
		sb.append("\n");
		sb.append("<form nm='surepay' tl='充值确认' bl='充值' ol='check1()'>");
		sb.append("\n");
		sb.append("<a pic='11' nm='st'/><br/>");
		sb.append("\n");
		sb.append(" 你的输入的充值卡号为:<br/>");
		sb.append("\n");
		sb.append("<a nm='sk' c='ffffff'/><br/>");
		sb.append("\n");
		sb.append("你的输入的充值密码为:<br/>");
		sb.append("\n");
		sb.append("<a nm='sm' c='ffffff'/><br/>");
		sb.append("\n");
		sb.append("你选择的充值金额为:<br/>");
		sb.append("\n");
		sb.append("<a nm='sj' c='ffffff'/><br/>");
		sb.append("\n");
		sb.append("<a");
		sb.append("\n");
		sb.append("c='ff00000'>充值时你务必选择与充值卡面额相同的金额，否则会导致充值失败和充值卡报废。此规定为充值卡系统规定，请玩家务必注意。</a>");
		sb.append("\n");
		sb.append(" 此规定为充值卡系统规定，敬请谅解。因充值面额不符导致的充值失败或充值卡报废，损失由用户自行承担。");
		sb.append("\n");
		sb.append("<s>");
		sb.append("\n");
		sb.append("sub check1()");
		sb.append("\n");
		sb.append("action(\"send:150:b\"+getVal(\"st\")+\":u\"+getText(\"sk\")+\":u\"+getText(\"sm\")+\":s\"+getText(\"sj\"))");
		sb.append("\n");
		sb.append("back(3)");
		sb.append("\n");
		sb.append("ret");
		sb.append("\n");
		sb.append("</s></form></form></form>");
		getClient().getActiveChar().sendPacket(new GUIList(sb.toString()));

	}

}
